/*
    This file is part of Emu.

    Emu is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Emu is distributed in the hope that it will be useful,
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Emu.  If not, see <http://www.gnu.org/licenses/>. */
#ifndef EMAINWINDOW_H
# define EMAINWINDOW_H

# include <QAction>
# include <QDir>
# include <QMainWindow>
# include <QTabWidget>
# include <QCloseEvent>

# include "eglobalprefs.h"
# include "esession.h"

class EMainWindow : public QMainWindow
{
    Q_OBJECT

public:
    EMainWindow();
    ~EMainWindow();
    void start();

private:
    EGlobalPrefs *_globalPrefs;
    ESession *_currentSession;

    QAction *_cutAct;
    QAction *_copyAct;
    QAction *_editSessionAct;
    QAction *_findNextAct;
    QAction *_findPrevAct;
    QAction *_fontAct;
    QAction *_nextSessionAct;
    QAction *_pasteAct;
    QAction *_prevSessionAct;
    QAction *_quitSessionAct;
    QAction *_redoAct;
    QAction *_saveLogAct;
    QAction *_saveLogAsAct;
    QAction *_showFindAct;
    QAction *_selectAllAct;
    QAction *_undoAct;

    QList<ESession *> _sessions;
    QTabWidget *_display;

    QString promptToSaveLog(QString, bool);
    void closeEvent(QCloseEvent *);
    void setEditItemsEnabled(bool);
    void createSession(EProfile *);
    void createFileMenu();
    void createEditMenu();
    void createSessMenu();
    void createMenus();
    bool promptCloseSession(ESession *);

private slots:
    void currentChanged(int);
    void catchClipboardChanged();
    void catchFocusChanged();
    void closeTab(int);

    void toggleUndoEnabled(bool);
    void toggleRedoEnabled(bool);
    void toggleCopyEnabled(bool);
    void toggleCutCopyEnabled(bool);

    /* The rest is all menu actions. */
    void copy();
    void cut();
    void editSession();
    void findNext();
    void findPrevious();
    void newSession();
    void nextSession();
    void paste();
    void prevSession();
    void quitSession();
    void redo();
    void saveLog();
    void saveLogAs();
    void selectAll();
    void showFontDialog();
    void showSearchBar();
    void undo();
};

#endif

